package com.mahees.portfolio.controller

import com.mahees.portfolio.domain.*;

class DefaultController {

	def index = {
		
		List<DevelopmentToolTypeEnum> toolsDisplayOrder = [
			DevelopmentToolTypeEnum.FRAMEWORK,
			DevelopmentToolTypeEnum.LANGUAGE,
			DevelopmentToolTypeEnum.IDE,
			DevelopmentToolTypeEnum.PLATFORM,
			DevelopmentToolTypeEnum.OTHER,
		]

		LinkedHashMap<DevelopmentToolTypeEnum, List<DevelopmentTool>> developmentTools =
				DevelopmentTool.list().groupBy { it.toolType };

		LinkedHashMap<DevelopmentToolTypeEnum, List<DevelopmentTool>> toolsOrderedByType = [:]
		toolsDisplayOrder.each {
			!developmentTools[it] ?: toolsOrderedByType <<  [(it) : developmentTools[it]]
		}

		withFormat {
			html { [tools: toolsOrderedByType] }
		}
	}
}
